home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / music / eked-m1.zoo / src / gm / gem_man.h < prev    next >
C/C++ Source or Header  |  1995-02-19  |  8KB  |  269 lines

  1. /*
  2.  *  EKED-M1 : Editor for Korg M1 synth; gem_man.h : GEM defines/types/externs
  3.  *  Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #define ED_START    0
  21. #define ED_INIT        1
  22. #define ED_CHAR        2
  23. #define ED_END        3
  24.  
  25. #define DESK        0
  26. #define MAX_WINDOWS    16
  27. #define MAX_EQUIV    64
  28. #define OUT_OF_WINDOWS    (-1)
  29. #define OUT_OF_MEMORY    (-2)
  30.  
  31. typedef enum {
  32.   E_CLICK,         /* mouse click in window */
  33.   E_MESSAGE,        /* AES message to window */
  34.   E_DRAG,        /* object dragged onto window */
  35.   E_DROP,        /* object dropped onto window */
  36.   E_DRAGEXIT,        /* object dragged out of window */
  37.   E_USER,        /* non-AES message sent to window by wm_send_user() */
  38.   E_CLEANUP,        /* window about to be closed, only handle, type and */
  39.                         /* usr_val are valid */
  40.   E_KEYPRESS        /* key pressed while mouse over window */
  41. } E_TYPE;
  42.  
  43. typedef struct {
  44.   int n_clks;        /* number of clicks */
  45.   int m_state;        /* mouse state */
  46.   int m_x;        /* mouse x position (or cell x-coord for list window) */
  47.   int m_y;        /* mouse y position (or cell y-coord for list window) */
  48. } CLICK;
  49.  
  50. typedef struct {
  51.   int k_state;        /* state of shift/ctrl/alt keys */
  52.   int k_ret;        /* physical (hi-byte) & ASCII (lo-byte) codes */
  53. } KEYPRESS;
  54.  
  55. typedef struct {
  56.   int m_x;        /* mouse x position */
  57.   int m_y;        /* mouse y position */
  58.   long object;        /* (probably pointer to) object */
  59. } DRAG_DROP;
  60.  
  61. typedef struct {
  62.   int code;            /* key and shift status code */
  63.   int title;            /* number of menu title object */
  64.   int item;            /* number of menu item object */
  65. } KEY_EQUIV;
  66.  
  67. /*
  68.  *    Return values from action function
  69.  */
  70. #define R_NORMAL    0
  71. #define R_QUIT        1
  72. #define R_NOACT        2
  73.  
  74. /*
  75.  *    Value rolling modes
  76.  */
  77. #define R_ROLL        0
  78. #define R_RIGHTUP    1
  79. #define R_LEFTUP    2
  80.  
  81. /*
  82.  *    Macros
  83.  */
  84. #define GM_DEBUG(t,v)                            \
  85. {                                    \
  86.   char alert[256];                            \
  87.   sprintf(alert, "[1][%s = %d][ CONT ]", t, v);                \
  88.   form_alert(1, alert);                            \
  89. }
  90.  
  91. #define GM_BOUND_FIX(v, min, max)                    \
  92.   if((v) > (max))                            \
  93.     (v) = (max);                            \
  94.   else if((v) < (min))                            \
  95.     (v) = (min)
  96.  
  97. #define GM_AES2VDI(point, rect)                        \
  98. (                                    \
  99.   (point)[0] = (rect)->g_x,                        \
  100.   (point)[1] = (rect)->g_y,                        \
  101.   (point)[2] = (rect)->g_x + (rect)->g_w - 1,                \
  102.   (point)[3] = (rect)->g_y + (rect)->g_h - 1                \
  103. )
  104.  
  105. #define GM_SELECT(flag, tree, ob)                    \
  106. (                                    \
  107.   (tree)[ob].ob_state = (flag) ? ((tree)[ob].ob_state | SELECTED) :    \
  108.                                  ((tree)[ob].ob_state & ~SELECTED)    \
  109. )
  110.  
  111. #define RDIV(a, b)    ((2 * (a) + (b)) / (2 * (b)))
  112. #define MALLOC(t)    ((t *) malloc(sizeof(t)))
  113. #define FREE(p)        (free((void *) (p)))
  114.  
  115. /*
  116.  *    AES new flags
  117.  */
  118. #ifndef FL3DIND
  119. #define FL3DIND        0x0200
  120. #endif
  121.  
  122. #ifndef FL3DACT
  123. #define FL3DACT        0x0400
  124. #endif
  125.  
  126. /*
  127.  *    Standard stuff
  128.  */
  129. #ifndef TRUE
  130. #define TRUE        1
  131. #endif
  132.  
  133. #ifndef FALSE
  134. #define FALSE        0
  135. #endif
  136.  
  137. #ifndef MAX
  138. #define MAX(x, y)    (((x) >= (y)) ? (x) : (y))
  139. #endif
  140.  
  141. #ifndef MIN
  142. #define MIN(x, y)    (((x) <= (y)) ? (x) : (y))
  143. #endif
  144.  
  145. /*
  146.  *    Call-back function types
  147.  */
  148. typedef void (*DISP_FUNC_PTR)(int x_pos, int y_pos, GRECT *area, long usr_val);
  149. typedef int (*ACT_FUNC_PTR)(int handle, E_TYPE type, void *event,
  150.                             int x_pos, int y_pos, long usr_val);
  151. typedef int (*MENU_FUNC_PTR)(int title, int item);
  152. typedef void (*UPDATE_FUNC_PTR)(OBJECT *object, int value);
  153. typedef void (*REDRAW_FUNC_PTR)(OBJECT *tree, int ob, GRECT *area);
  154. typedef void (*POS_FUNC_PTR)(int x_pos, int y_pos);
  155. typedef int (*OBJECT_FUNC_PTR)(OBJECT *obj);
  156. typedef char *(*CELL_FUNC_PTR)(int x, int y, long usr_val);
  157.  
  158. /*
  159.  *    Global variables
  160.  */
  161. extern MFDB screen;
  162. extern int char_w, char_h;
  163. extern GRECT desk;
  164. extern int nr_planes;
  165. extern int gm_handle;
  166. extern USERBLK gm_button;
  167.  
  168. /*
  169.  *    External functions defined in gem_man.c and related macro
  170.  */
  171. #define gm_clsvwk(h)    v_clsvwk(h)
  172. void gm_init();
  173. void gm_exit();
  174. int gm_opnvwk();
  175. void gm_xorbox(GRECT *box);
  176. int gm_opaque(OBJECT *tree, int ob);
  177. int gm_roll_mode(int mode);
  178. int gm_roll(OBJECT *tree, int ob, int value, int min, int max,
  179.             UPDATE_FUNC_PTR update, REDRAW_FUNC_PTR redraw);
  180. int intersect(GRECT *r1, GRECT *r2);
  181.  
  182. /*
  183.  *    External functions defined in rsc_man.c
  184.  */
  185. int rm_load(char *filename);
  186. int rm_free(void);
  187. int rm_gaddr(int type, int index, void *addr);
  188. void rm_map_tree(OBJECT *tree, OBJECT_FUNC_PTR func);
  189. void rm_map_all(OBJECT_FUNC_PTR func);
  190.  
  191. /*
  192.  *    External functions defined in wind_man.c and related macros
  193.  */
  194. #define wm_init()        /* no op */
  195. #define wm_update(handle)    wm_send_redraw(handle, (GRECT *) NULL)
  196. void wm_exit();
  197. void wm_getdata(int handle, int *x_pos, int *y_pos, long *usr_val);
  198. void wm_send_redraw(int handle, GRECT *area);
  199. void wm_send_user(int handle, long object);
  200. void wm_redraw(int handle, GRECT *area);
  201. int wm_open(int parts, GRECT *init, char *title,
  202.             int con_w, int con_h, int x_scroll, int y_scroll,
  203.             DISP_FUNC_PTR display, ACT_FUNC_PTR action, long usr_val);
  204. void wm_closed(int h);
  205. void wm_moved(int handle, GRECT *area);
  206. void wm_sized(int handle, GRECT *area);
  207. void wm_fulled(int handle);
  208. void wm_arrowed(int handle, int dir);
  209. void wm_hslid(int handle, int pos);
  210. void wm_vslid(int handle, int pos);
  211. void wm_topped(int handle);
  212. void wm_flush(int redraw_flag);
  213. void wm_monitor(OBJECT *menu, MENU_FUNC_PTR menu_handler);
  214. void wm_cycle();
  215. int wm_roll(int handle, OBJECT *tree, int ob, int value,
  216.             int min, int max, UPDATE_FUNC_PTR update);
  217. void wm_ob_update(int handle, OBJECT *tree, int ob);
  218. void wm_ob_redraw(int handle, OBJECT *tree, int ob, GRECT *area);
  219. int wm_do_button(int handle, OBJECT *tree, int ob, int toggle);
  220. void wm_dragbox(GRECT *position, long object);
  221.  
  222. /*
  223.  *    External functions defined in key_man.c
  224.  */
  225. KEY_EQUIV *km_get_equiv(int k_state, int k_ret);
  226. void km_set_equiv(int k_state, int k_ret, int title, int item);
  227. void km_scan_menu(OBJECT *menu);
  228.  
  229. /*
  230.  *    External functions defined in form_man.c and related macro
  231.  */
  232. #define fm_roll(tree, ob, value, min, max, update) \
  233.   gm_roll(tree, ob, value, min, max, update, &fm_ob_redraw)
  234. int fm_dialog(OBJECT *tree, int ed, OBJECT *org_tree, int org_ob);
  235. void fm_begin_dialog(OBJECT *tree, int ed);
  236. int fm_run_dialog();
  237. void fm_end_dialog();
  238. int fm_form_do(OBJECT *tree, int ed);
  239. char *fm_file_select(char *title, char *mask, char *filename);
  240. void fm_ob_redraw(OBJECT *tree, int ob, GRECT *area);
  241. int fm_alert(int but, int n);
  242.  
  243. /*
  244.  *    External functions defined in mag.c and related macro
  245.  */
  246. #define mg_exit()    /* no op */
  247. void mg_init();
  248. void magnify();
  249.  
  250. /*
  251.  *    External functions defined in list_man.c
  252.  */
  253. int lm_open(GRECT *init, char *title,
  254.             int x_cells, int y_cells, int x_sep, int y_sep,
  255.             int width, int text_size, int b_color, int t_color,
  256.             CELL_FUNC_PTR content, ACT_FUNC_PTR usr_action, long usr_val);
  257. void lm_update(int handle, int x, int y);
  258. void lm_dragbox(int handle, int x, int y, long item);
  259.  
  260. /*
  261.  *    Misc macros
  262.  */
  263. #define BEG_BUSY    (wm_flush(TRUE), graf_mouse(HOURGLASS, 0L))
  264. #define BEG_DRAG    graf_mouse(FLAT_HAND, 0L)
  265. #define BEG_SIZE    graf_mouse(POINT_HAND, 0L)
  266. #define END_BUSY    graf_mouse(ARROW, 0L)
  267. #define END_DRAG    graf_mouse(ARROW, 0L)
  268. #define END_SIZE    graf_mouse(ARROW, 0L)
  269.